package com.myapp.ruyixing.http;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

import com.myapp.ruyixing.model.MyOrderList;
import com.myapp.ruyixing.model.MyOrderList.Order;

public class MyOrderListParser extends RYJSONParser {
	@Override
	public Object parse(JSONObject jsonObject) {
		MyOrderList list = new MyOrderList();

		ListModelParser.parseListModel(list, jsonObject);
		JSONObject data = jsonObject.optJSONObject("data");
		JSONArray array = data.optJSONArray("list");
		list.list = new ArrayList<Order>();
		for (int i = 0; array != null && i < array.length(); i++) {
			JSONObject object = array.optJSONObject(i);
			if (object != null) {
				Order item = new Order();
				item.content = object.optString("content", "");
				item.mobile = object.optString("mobile", "");
				item.name = object.optString("name", "");
				item.datetime = object.optString("datetime", "");
				item.shopname = object.optString("shopname", "");
				item.status = object.optString("status", "");
				list.list.add(item);
			}
		}

		return list;

	}
}
